package com.yunche.yunchebusiness.ui.activity.system

import com.yunche.yunchebusiness.R
import com.yunche.yunchebusiness.base.BaseActivity
import com.yunche.yunchebusiness.common.CommonDialog
import com.yunche.yunchebusiness.common.Constant
import com.yunche.yunchebusiness.entity.UserEntity
import com.yunche.yunchebusiness.mvp.contract.UserContract
import com.yunche.yunchebusiness.mvp.presenter.UserPresenter
import com.yunche.yunchebusiness.utils.ToastyUtils
import kotlinx.android.synthetic.main.activity_user_info.*

class UserInfoActivity : BaseActivity(), UserContract.View {

    private val mPresenter by lazy {
        UserPresenter()
    }

    override fun getUserInfoSuccess(userEntity: UserEntity) {
        tv_user_job.text = userEntity.tenant.contactPosition
        tv_user_name.text = userEntity.tenant.contactName
        tv_user_tenant.text = userEntity.tenant.name
        tv_user_nike_name.text = userEntity.tenant.contactName
        tv_user_phone.text= userEntity.tenant.contactMobile
    }

    override fun changeUserInfoSuccess() {

    }

    override fun showLoading() {
        CommonDialog.showLoading(mContext!!, Constant.Loading)
    }

    override fun hideLoading() {
        CommonDialog.cancle()
    }

    override fun showError(msg: String) {
        ToastyUtils.showError(msg)
    }

    override fun setLayout(): Int = R.layout.activity_user_info

    override fun initView() {
        mPresenter.attachView(this)
    }

    override fun initData() {
        mPresenter.getUserInfo()
    }

    override fun initEvent() {

    }

    override fun onDestroy() {
        super.onDestroy()
        mPresenter.detachView()
    }

}
